﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;

namespace App1AppHandler
{
    public class SpellIcon
    {
        public int ID_DB = -1;
        public string Name = "";
        public string ClassName = "";
        public string CastType = "";
        public string SpellType = "";
        public string ImageURL = "";
        public string FieldImageURL = "";
        public string Description = "";
        public bool Offensive = false;
        public int ManaCost = 0;
        public string StackType = "";

        //Used for creature AI to determine if AOE will hit allies
        public int AreaRadius = 1;

        public int LevelRequired = 1;

        public int Cost = 0;
        public string Skill = "";

        public SpellIcon clone()
        {
            SpellIcon result = new SpellIcon();

            result.ID_DB = ID_DB;
            result.Name = Name;
            result.ClassName = ClassName;
            result.CastType = CastType;
            result.SpellType = SpellType;
            result.ImageURL = ImageURL;
            result.FieldImageURL = FieldImageURL;
            result.Description = Description;
            result.Offensive = Offensive;
            result.ManaCost = ManaCost;
            result.AreaRadius = AreaRadius;
            result.LevelRequired = LevelRequired;
            result.Skill = Skill;
            result.Cost = Cost;
            result.StackType = StackType;

            return result;
        }

        public string toXML()
        {
            string result = "";

            StringWriter stringWriter = new StringWriter();
            XmlTextWriter xmldoc = new XmlTextWriter(stringWriter);
            
            xmldoc.WriteStartElement("spellicon");
            xmldoc.WriteAttributeString("ID_DB", ID_DB.ToString());
            xmldoc.WriteAttributeString("Name", Name.ToString());
            xmldoc.WriteAttributeString("ClassName", ClassName.ToString());
            xmldoc.WriteAttributeString("CastType", CastType.ToString());
            xmldoc.WriteAttributeString("SpellType", SpellType.ToString());
            xmldoc.WriteAttributeString("ImageURL", ImageURL.ToString());
            xmldoc.WriteAttributeString("Description", Description.ToString());
            xmldoc.WriteAttributeString("Offensive", Offensive.ToString());
            xmldoc.WriteAttributeString("Cost", Cost.ToString());
            xmldoc.WriteAttributeString("LevelRequired", LevelRequired.ToString());
            xmldoc.WriteAttributeString("Skill", Skill);
            xmldoc.WriteAttributeString("ManaCost", ManaCost.ToString());

            xmldoc.WriteEndElement();
            xmldoc.Flush();

            xmldoc.Close();

            stringWriter.Flush();

            result = stringWriter.ToString();

            return result;
        }
    }
}
